<template>
  <div>
    <!--头部-->
    <div style="display: flex;height: 61px; line-height: 60px; border-bottom: 1px solid #ccc">
      <div style="display:flex; width: 300px; padding-left: 30px">
        <div>
          <img src="../../assets/EDG.png" alt="" style="width: 50px; position: relative;top: 10px;right: 10px">
        </div>
        <span style="flex: 1">我推の孩子官网</span>
      </div>
      <!--      导航菜单-->
      <div style="flex: 1">
        <!--        <ul style="background-color:  #424242">-->
        <!--          <li class="item">-->
        <!--            <el-dropdown style="font-size: 16px" size="medium">-->
        <!--              <a href="">-->
        <!--                菜单1<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
        <!--              </a>-->
        <!--              <el-dropdown-menu slot="dropdown">-->
        <!--                <el-dropdown-item>黄金糕</el-dropdown-item>-->
        <!--                <el-dropdown-item>狮子头</el-dropdown-item>-->
        <!--                <el-dropdown-item>螺蛳粉</el-dropdown-item>-->
        <!--                <el-dropdown-item>双皮奶</el-dropdown-item>-->
        <!--                <el-dropdown-item>蚵仔煎</el-dropdown-item>-->
        <!--              </el-dropdown-menu>-->
        <!--            </el-dropdown>-->
        <!--          </li>-->
        <!--          <li class="item"><a href="/"> 菜单2</a></li>-->
        <!--          <li class="item"><a href="/"> 菜单3</a></li>-->
        <!--          <li class="item"><a href="/"> 菜单4</a></li>-->
        <!--        </ul>-->
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" active-text-color="blue"
                 router>
          <el-menu-item index="/front/home">我推的孩子主页</el-menu-item>
          <el-menu-item index="/front/video">视频播放</el-menu-item>
          <el-submenu index="2">
            <template slot="title">人物介绍</template>
            <el-menu-item index="/front/love">关于星野爱</el-menu-item>
            <el-menu-item index="/front/akuiya">关于阿奎亚</el-menu-item>
            <el-menu-item index="/front/lub">关于露比</el-menu-item>
          </el-submenu>
          <el-menu-item index="/front/plot">剧情介绍</el-menu-item>
          <el-menu-item><a style="text-decoration: none"
                           href="https://www.myanimehouse.com/zh-hans/anime/WLk29dl3/%E3%80%90%E6%88%91%E6%8E%A8%E7%9A%84%E5%AD%A9%E5%AD%90%E3%80%91"
                           target="_blank">更多详情</a></el-menu-item>
        </el-menu>
      </div>
      <div style="width: 200px">
        <div v-if="!user.username" style="text-align: right; padding-right: 30px">
          <el-button @click="$router.push('/login')">登录</el-button>
          <el-button @click="$router.push('/register')">注册</el-button>
        </div>
        <div v-else>
          <el-dropdown style="width: 150px; cursor: pointer;text-align: right">
            <div style="display: inline-block">
              <img :src="user.avatarUrl" alt=""
                   style="width: 30px; border-radius: 50%; position: relative; top: 10px; right: 5px">
              <span>{{ user.nickname }}</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
            </div>
            <el-dropdown-menu slot="dropdown" style="width: 100px; text-align: center">
              <el-dropdown-item style="font-size: 14px; padding: 5px 0">
                <router-link to="/front/password" style="text-decoration: none">修改密码</router-link>
              </el-dropdown-item>
              <el-dropdown-item style="font-size: 14px; padding: 5px 0">
                <router-link to="/front/person" style="text-decoration: none">个人信息</router-link>
              </el-dropdown-item>
              <el-dropdown-item style="font-size: 14px; padding: 5px 0">
                <span to="/login" style="text-decoration: none" @click="logOut">退出</span>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>

      </div>
    </div>
    <div style="width: 1246px; margin-left: 300px; margin-top: 20px">

      <router-view/>

    </div>

  </div>
</template>

<script>
export default {
  name: "Front",
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
      activeIndex: '/front/home'
    }
  },
  methods: {
    logOut() {
      this.$store.commit("logout")
      this.$message.success("退出成功")
    }
  }
}
</script>

<style scoped>
.item {
  display: inline-block;
  width: 100px;
  /*color: #3F5EFB;*/
  text-align: center;
  cursor: pointer;
  /*background-color: black;*/
}

.item a {
  text-decoration: none;
  color: white;
}

.item:hover {
  background-color: black;
}
</style>